package nina.yiyou.attendance.s10merge.compute.latepoint

import groovy.transform.PackageScope
import nina.yiyou.attendance.s10merge.compute.AttendDetailMerger
import nina.yiyou.attendance.s10merge.compute.offgain.DeltaDayFinder

import java.time.LocalDate

@PackageScope
class PreviousDayFinder {

  PreviousDayFinder(AttendDetailMerger.PunchDay curDay, List<AttendDetailMerger.PunchDay> dayList) {
    _curDay = curDay
    _dayList = dayList
  }

  Optional<AttendDetailMerger.PunchDay> find() {
    return new DeltaDayFinder(_curDay, { LocalDate d -> d.minusDays(1) }, _dayList).find()
  }

  private final AttendDetailMerger.PunchDay _curDay

  private final List<AttendDetailMerger.PunchDay> _dayList
}
